<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="<%=request.getContextPath()%>/resource/js/jquery-1.8.3.min.js"></script>
<link href="<%=request.getContextPath()%>/resource/css/index3.css" rel="stylesheet">

</head>
<body>
	<center>
		<form action="tiaos" method="post">
			学生：<select name="sid">
					<option value="">===请选择===</option>
					<c:forEach items="${list}" var="s">
						<option value="${s.id}">${s.name}</option>
					</c:forEach>
				 </select><br>
			楼号：<select name="fid" id="fid">
				 	<option value="">===请选择===</option>
				 </select><br>
			宿舍号：<select name="did" id="did">
				 	
				 </select><br>
				 <input type="submit" value="调室">
		</form>
	</center>
	<script type="text/javascript">
		$.post(
			"selFloor",
			function(msg) {
				if (msg!=null) {
					for (var i = 0; i < msg.length; i++) {
						$("#fid").append("<option value='"+msg[i].id+"'>"+msg[i].floorNo+"</option>")
					}
				}
			},
			"json"
		)
		$("#fid").change(function() {
			var fid = $("#fid").val();
			$("#did").html("");
			$("#did").append("<option value=''>===请选择===</option>");
			$.post(
				"selDrom",
				{fid:fid},
				function(msg) {
					if (msg!=null) {
						for (var i = 0; i < msg.length; i++) {
							$("#did").append("<option value='"+msg[i].id+"'>"+msg[i].dromNo+"</option>")
						}
					}
				},
				"json"
			)
		})
	</script>
</body>
</html>